// let baseURI = "http://47.108.153.85:9291"
// let baseURI = "http://39.101.150.157:9291"
let baseURI = "http://cjkl.vaiwan.com"
let token = "eyJhbGciOiJIUzUxMiJ9.eyJqdGkiOiIxNDMyMzYwODQ0OTI4Mzk3MzE0Iiwic3ViIjoiY2VzaGkwMDEiLCJpYXQiOjE2MzQ3MTQ0MjQsImlzcyI6IlNDUk0ifQ.WcXbYZ-lvM5Y8RDhTu7SiEfxnvl25LsT_sDt4PCMP0uneR9y_Zqk-jgZuqSa5UUIQfk4LCzAlBaH0TQliRy4nQ"
let tokenKey = "f2d882cd-36de-472a-b7c0-34506188b277"

let http = function(reqBody) {
	let {
		url,
		method,
		data
	} = reqBody;
	let header = {}
	let {
		token,
		tokenKey
	} = uni.getStorageSync("loginInfo")

	if (token) {
		header = {
			"Authorization": token,
			"Authorization-key": tokenKey
		}
	}
	return new Promise((resolve,reject)=>{
		uni.request({
			method,
			url: baseURI + url,
			data,
			header,
			success: (res) => {
				let result = res.data
				// if(result.code == 500) {
				// 	uni.showToast({
				// 		title:"服务器错误",
				// 		icon:"none",
				// 		duration:2000
				// 	})
				// 	reject(result)
				// } else {
				// }
					resolve(result)
			},
			fail: (e) => {
				reject(e)
			}
		})
	})
}

export default http;
